function exclusiveTime(n: number, logs: string[]): number[] {
    let lastInfo:(number|string)[][] = []
    let time: number
    const ans: number[] = new Array(n).fill(0)
    logs.forEach((item) => {
        const iArr = item.split(":")
        if(lastInfo.length > 0 ){
            if(lastInfo[0][1] === 'start' && iArr[1] === 'start'){
                ans[Number(lastInfo[0][0])] += Number(iArr[2]) - time - 1
                lastInfo.unshift(item.split(":"))
                time = Number(iArr[2])
            }else if(lastInfo[0][1] === 'start' && iArr[1] === 'end'){
                ans[Number(iArr[0])] += Number(iArr[2]) - time + 1
                lastInfo.shift()
                time = Number(iArr[2])
            }else if(lastInfo[0][1] === 'end' && iArr[1] === 'end'){
                ans[Number(iArr[0])] += Number(iArr[2]) - time
                lastInfo.shift()
                lastInfo.shift()
                time = Number(iArr[2])
            }else if(lastInfo[0][1] === 'end' && iArr[1] === 'start'){
                ans[Number(lastInfo[0])] += Number(iArr[2]) - time - 1
                lastInfo.shift()
                lastInfo.unshift(item.split(":"))
                time = Number(iArr[2])
            }
            console.log(ans,iArr,time,lastInfo)
        }else {
            lastInfo.unshift(iArr)
            time = Number(iArr[2])
        }
        
    })
    return ans
};


const n:number = 2
const logs:string[] = ["0:start:0","0:start:2","0:end:5","1:start:7","1:end:7","0:end:8"]
console.log(exclusiveTime(n,logs))